package org.imlinker.setting;

import java.io.File;

/**
 * 用户的帐号.
 */
public class Settings extends Object {

	public Settings(final String path, final String userWithResource) {

		String user = userWithResource.substring(0, userWithResource
				.indexOf("/"));
		String userToFile = user.replaceAll("@", "at");
		this.path = path + File.separator + "config" + File.separator
				+ userToFile + ".xml";

		file = new SettingFile("userSetting", this.path);

		if (file.getValue("userid") == null) {
			file.setValue("userid", user);
			file.save();
		}

	}

	public void deleteValue(final String url) {
		file.deleteValue(url);
	}

	public boolean getBooleanAt(final String url) {
		return file.getBooleanValue(url);
	}

	public int getElementSize(final String url) {
		return file.getElementSize(url);
	}

	public String getValue(final String url) {
		return file.getValue(url);
	}

	public void save() {
		file.save();
	}

	public void setValueAt(final String url, final String value) {
		file.setValue(url, value);
	}

	private String path;

	private SettingFile file;

}
